/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package toster;

import java.util.EventListener;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *  this thread keeps track of activity in the third pass
 * @author rcluster
 */
public class WatchedPot extends Thread{
    private boolean hasChanged=false;
    private watcher watchman=new watcher();
   /**
    * this is the working part of the thread, if it detects that there is 
    * no activity in the past .10 seconds it dies off 
    */
    public void run(){
        while(true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(WatchedPot.class.getName()).log(Level.SEVERE, null, ex);
            }

            if(hasChanged)
                hasChanged=false;
            else break;
        }
    }
    /**
     * this sets haschanged to true if something has changed
     */
    class watcher implements EventListener{

        public void eventDispatched(GridEvent in){
            hasChanged=true;
        }
    }
}
